package com.study.manage.dal;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.study.manage.domain.BlogHeart;
import com.study.manage.domain.enumm.LiveDieState;


public interface BlogHeartRepository
        extends PagingAndSortingRepository<BlogHeart, Long>, JpaSpecificationExecutor<BlogHeart> {

    @Query("select sum(t.number) from BlogHeart t where t.userId=:userId and t.state=:state")
    Integer sumCountByBlogUserIdAndState(@Param("userId") Long userId,@Param("state") LiveDieState state);

    @Query("select sum(t.number) from BlogHeart t where t.blogId=:blogId and t.state=:state")
    Integer sumCountByBlogIdAndState(@Param("blogId") Long blogId,@Param("state") LiveDieState state);


}
